package org.lq.rbac.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
    public  static  String md5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md5=MessageDigest.getInstance("md5");

            byte [] input =text.getBytes("utf8");
            byte [] bytes=md5.digest(input);

            StringBuilder sb=new StringBuilder();

            for (int i=0;i<bytes.length;i++){
                sb.append(String.format("%02x",bytes[i]));


            }
            return sb.toString();
    }
}
